package com.landeb.shop.huo.act;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;

import com.landeb.shop.R;
import com.landeb.shop.huo.BannerLoader;
import com.landeb.shop.huo.adapter.QuackPagerAdapter;
import com.youth.banner.Banner;

import java.util.ArrayList;
import java.util.List;

import me.relex.circleindicator.CircleIndicator;

public class WelcomeActivity extends BaseActivity {

    private List<View> images = new ArrayList<>();
    private ViewPager pager;
    private CircleIndicator indicator;
    public static void toAct(Context context) {
        Intent intent = new Intent(context, WelcomeActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);

        /** 绑定视图*/
        initView();

        /** 初始化数据*/
        initData();

//      initFakeData();

        /** 绑定事件*/
        initEvent();


//        //设置图片加载器
//        banner.setImageLoader(new BannerLoader());
//        //设置图片集合
//        banner.setImages(images);
//        banner.isAutoPlay(false);
//        //banner设置方法全部调用完毕时最后调用
//        banner.start();
    }

    private void initEvent() {
        QuackPagerAdapter<View> adapter = new QuackPagerAdapter<>(images);
        pager.setAdapter(adapter);
        indicator.setViewPager(pager);

    }

    private void initData() {

        for (int i = 0; i < 5; i++) {
            View viewTest = LayoutInflater.from(this).inflate(R.layout.item_welcome_act, null);
            images.add(viewTest);
        }
    }

    private void initView() {
         pager=(ViewPager) findViewById(R.id.welcome_act_banner);
         indicator = (CircleIndicator)findViewById(R.id.welcome_act_indicator);

    }
}
